#include<iostream>//D
#include<cstdio>
using namespace std;
int n,qa,cnt;
bool f[200001];
struct node{
	int z,l,r,ans;
	int front,next;
}a[200001];
int main()
{
	freopen("fruit.in","r",stdin);
	freopen("fruit.out","w",stdout);
	scanf("%d",&n);
	cnt=n;
	for(int i=1;i<=n;i++)
	{
		int x;
		scanf("%d",&x);
		if(qa==0||a[qa].z!=x)qa++,a[qa]=((node){x,i,i,1,qa-1,qa+1});
		else a[qa].ans++,a[qa].r++;
	}
	a[0].next=1;
	while(cnt)
	{
		for(int i=a[0].next;a[i].ans>0;i=a[i].next)
		{
			while(f[a[i].l]==1)a[i].l++;
			printf("%d ",a[i].l);
			f[a[i].l]=1,a[i].l++,a[i].ans--,cnt--;
			if(a[i].ans==0)
			{
				int L=a[i].front,R=a[i].next;
				a[L].next=R,a[R].front=L;	
			}
		}
		for(int i=a[0].next;a[i].ans>0;i=a[i].next)
		{
			int R=a[i].next;
			if(a[R].ans>0&&a[R].z==a[i].z)
			{
				a[i].next=a[R].next,a[a[R].next].front=i;
				a[i].r=a[R].r,a[i].ans+=a[R].ans;
			}
		}
		printf("\n"); 
	}
	return 0;
}
